Field of the Invention
The invention relates generally to software programming and, more particularly, to multithreaded programming techniques.
Description of the Background Art
Many high-performance computing applications are written using multithreading techniques. When using a multithreading technique, multiple threads of execution can work on different tasks either concurrently or by alternating access to a processing pipeline. For example, if a task can be broken down into two distinct sub-tasks, it may be useful to create two separate threads, each one handling a different sub-task. These threads then produce their corresponding results, which together solve the overall task.
Different techniques exist for assigning work to a task. One approach is commonly termed, “producer-consumer design.” Within a producer-consumer design approach, one or more threads are responsible for producing data, and one or more threads are responsible for consuming the produced data. As an example, a producer thread may be responsible for reading data from a file into a memory area accessible by a consumer thread. The consumer thread retrieves the data from that memory area and processes (consumes) the data as needed.
As the responsibilities of consumer threads become more complex, the consumer thread's resource requirements also typically become more complex. In the producer-consumer design approach, consumer threads are available to handle data as data arrives into the memory area from the producer thread. This requirement for consumer threads to remain resident in memory requires excessive resource utilization. Additionally, swapping consumer threads in and out of active memory is also expensive (with respect to, for example, excessive processing cycles, time to completion, power, and other aspects), even in situations when a consumer thread may not be performing any operations if the memory area is empty.
Accordingly, what is desired is a technique to reduce the resource requirements of consumer threads.